package com.weijian.dal.dto.study;

import com.weijian.dal.enums.StudyStatus;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 学习记录DTO
 */
@Data
public class StudyRecordDTO {

    private Long id;
    private Long userId;
    private Long courseId;
    private String courseTitle;
    private StudyStatus status;
    private String statusName;
    private Integer progressPercent;
    private Integer totalChapters;
    private Integer completedChapters;
    private LocalDateTime firstStudyTime;
    private LocalDateTime lastStudyTime;
    private LocalDateTime completionTime;
    private Long studyDuration;
    private Integer remainingChapters;
    private Long estimatedRemainingTime;

    /**
     * 获取剩余章节数
     */
    public Integer getRemainingChapters() {
        return totalChapters - completedChapters;
    }

    /**
     * 获取预计剩余时间（分钟）
     */
    public Long getEstimatedRemainingTime() {
        if (completedChapters == 0 || studyDuration == 0) {
            return 0L;
        }

        long avgTimePerChapter = studyDuration / completedChapters;
        return avgTimePerChapter * getRemainingChapters();
    }
}